<?php
class Api_Row_Authors extends Api_Row_Base
{
    protected $_date;

    public function __construct($config)
    {
        parent::__construct($config);
        $this->_date = new Zend_Date ($this->date, Zend_Date::TIMESTAMP);
        $this->_data ['year'] = $this->_date->get(Zend_Date::YEAR);
    }

    public function getYear()
    {
        return $this->_date->get(Zend_Date::YEAR);
    }

    public function Location()
    {
        return $this -> location;
    }

    public function Url()
    {
        return $this -> _assemble(
            array(
                'controller' => 'author',
                'action' => 'details',
                'id' => $this -> id
            ), NULL, TRUE
        );
    }

    public function Name()
    {
        return $this -> authors_name;
    }

    public function Profession()
    {
        return $this -> _table -> getManager() -> Profession -> getOne( $this -> profession_id ) -> Name();
    }

     public function Description()
     {
         return $this -> description;
     }

    public function FullDescription()
    {
        if( NULL === $this -> full_description ) return $this -> description;
        return $this -> full_description;
    }

    public function AvatarUrl()
    {
     if( 0 == $this -> image_id ) return '/image/author/no_img.jpg';
     return "/image/author/{$this->image_id}.jpg";
    }

    public function AllWorksUrl()
    {
        return $this -> _assemble(
            array(
                'controller' => 'author',
                'action' => 'works',
                'author' => $this -> id
            ), NULL, true
        );
    }
    
}